package com.bjc.service;

import com.bjc.domain.Order;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.ConsumeMode;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Service;

/**
 * @program: spring-cloud-alibaba
 * @description: 监听消息发送短信
 * @author: bjc
 * @create: 2021-08-08 20:32
 */
@Slf4j
@Service
//consumerGroup-消费者组名  topic-要消费的主题
@RocketMQMessageListener(consumerGroup = "shop-user",topic = "order-topic"
        ,consumeMode = ConsumeMode.CONCURRENTLY //消费模式，指定是否顺序消费，CONCURRENTLY（同步，默认）ORDERLY（顺序）
        ,messageModel = MessageModel.CLUSTERING //消息模式    CLUSTERING（集群，默认） BROADCASTING(广播)
)
public class SmsService implements RocketMQListener<Order> {

    /**
     * 消费逻辑
     * @param message
     */
    @Override
    public void onMessage(Order message) {
        log.info("接收到了一个订单消息{}，揭晓来就可以发送短信通知了",message);
    }
}
